package com.example.tiroaoalvo;

import android.R.color;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.opengl.GLSurfaceView;
import android.util.Log;
import android.view.SurfaceHolder;

public class Game1 extends GLSurfaceView implements SurfaceHolder.Callback, Runnable
{ 
	
	private static final int INTERVAL = 10;
	private boolean running = true;
	private int y ;
	private Paint paint;
	
	
	
	
	
	
	public Game1(Context Content)
	{
		super(Content);
		
		paint = new Paint();
		Thread minhaThread = new Thread(this);
		minhaThread.setPriority(Thread.MIN_PRIORITY);
		minhaThread.start();
				

	}

	

	public void Draw(Canvas canvas)
	{
		onDraw(canvas);

	}

	public void run() {
		while(running){
			try{
				Thread.sleep(INTERVAL);
				
			}catch(Exception e ){
				Log.e("Erro", e.getMessage());
				
			}
			Update();
			
		}
		
	}
	public void Update()
	{
		if(y< getHeight()){
			y += 5;
			
		}
		else        {
			y = 0;
			
		}
		// dispara o metodo Draw para desenhar
		postInvalidate();
		
		}
	
	public void draw(Canvas canvas) {
		super.draw(canvas);
		
		canvas.drawColor(color.black);
		paint.setColor(Color.BLACK);
		
		canvas.drawColor(Color.BLUE);
		canvas.drawRect(getWidth()/2, y, getWidth()/2 + 50, y + 50, paint);
				
	}
	
	public void release() {
		
		running = false;
		
		
	}
	
}

